#include<iostream>
#include<string>
#include<vector>
#include<stack>
//https://leetcode.cn/problems/he-wei-sde-liang-ge-shu-zi-lcof/description/
using namespace std;

class Solution {
public:
    vector<int> twoSum(vector<int>& price, int target)
    {
        vector<int> ret;
        int left, right;
        left = 0, right = price.size() - 1;
        while (left < right)
        {
            if (price[left] + price[right] > target)
            {
                right--;
            }
            else if (price[left] + price[right] < target)
            {
                left++;
            }
            else
            {
                ret.push_back(price[left]);
                ret.push_back(price[right]);
                break;
            }

        }
        return ret;
    }
};

int main()
{

    vector<int>num = { 8, 21, 27, 34, 52, 66 };
    vector<int> ret = Solution().twoSum(num, 61);
    for (auto e : ret)
    {
        cout << e << " ";
    }
    return 0;
}
